package com.yaorange.nongjt.service.impl;

import com.yaorange.common.core.domain.model.LoginUser;
import com.yaorange.common.utils.SecurityUtils;
import com.yaorange.nongjt.domain.NjtYtjPos;
import com.yaorange.nongjt.mapper.NjtYtjPosMapper;
import com.yaorange.nongjt.service.NjtYtjPosService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;

import java.util.Date;
import java.util.List;

@Service
public class NjtYtjPosServiceImpl implements NjtYtjPosService {

    @Autowired
    private NjtYtjPosMapper njtYtjPosMapper;

    @Override
    @Transactional(readOnly = true)
    public List<NjtYtjPos> selectNjtYtjPosList(NjtYtjPos njtYtjPos) {
        return njtYtjPosMapper.selectNjtYtjPosList(njtYtjPos);
    }

    @Override
    public int insertNjtYtjPos(NjtYtjPos njtYtjPos) {
        njtYtjPos.setCreateTime(new Date());
        LoginUser loginUser = SecurityUtils.getLoginUser();
        njtYtjPos.setCreateBy(loginUser.getUsername());
        return njtYtjPosMapper.insertNjtYtjPos(njtYtjPos);
    }

    @Override
    public int updateNjtYtjPos(NjtYtjPos njtYtjPos) {
        njtYtjPos.setUpdateTime(new Date());
        LoginUser loginUser = SecurityUtils.getLoginUser();
        njtYtjPos.setUpdateBy(loginUser.getUsername());

        return njtYtjPosMapper.updateNjtYtjPos(njtYtjPos);
    }

    @Override
    public int batchDeleteNjtYtjPos(List<Long> ids) {
        return njtYtjPosMapper.batchDeleteNjtYtjPos(ids);
    }


}
